package com.cskaoyan.market.admin.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.cskaoyan.market.db.domain.MarketUser;
import com.cskaoyan.market.db.domain.MarketUserExample;
import com.cskaoyan.market.db.mapper.MarketUserMapper;
import com.cskaoyan.market.admin.service.MarketUserService;
import com.cskaoyan.market.util.MyBatisUtil;
import com.github.pagehelper.PageHelper;
import org.apache.ibatis.session.SqlSession;

import java.util.List;

/**
 * @author yuanixn2158@163.com
 * @since 2023/05/09 11:42
 */
@Service
public class MarketUserServiceImpl implements MarketUserService {
    @Autowired
    private MarketUserMapper mapper;
    @Override
    public List<MarketUser> getUserList(int page, int limit, String sort, String order) {
        MarketUserExample marketUserExample = new MarketUserExample();
        marketUserExample.orderBy(sort+" "+order);
        PageHelper.startPage(page,limit);
        List<MarketUser>marketUserList=mapper.selectByExample(marketUserExample);

        return marketUserList;
    }

    @Override
    public MarketUser Update(MarketUser updateMarketUser) {
        SqlSession sqlSession=MyBatisUtil.getSession();
        MarketUserMapper mapper = sqlSession.getMapper(MarketUserMapper.class);
        int i = mapper.updateByPrimaryKeySelective(updateMarketUser);
        MarketUser marketUser = mapper.selectByPrimaryKey(i);
        
        
        return marketUser;
    }

    @Override
    public MarketUser getUserDetail(int id) {
        MarketUser marketUser=mapper.selectByPrimaryKey(id);
        
        
        return marketUser;
    }
}
